package com.fyx.controller;


import com.fyx.annotation.Log;
import com.fyx.entity.*;
import com.fyx.service.IRunDataService;
import com.fyx.utils.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@Api(tags = "运营数据")
@RestController
@RequestMapping("/api/runData")
@RequiredArgsConstructor
public class RunDataController {
    @Autowired
    private IRunDataService iRunDataService;



    @Log("查询累计充值活跃用户")
    @ApiOperation("查询累计充值活跃用户")
    @GetMapping(value="allFeeActiveUser")
    @PreAuthorize("@el.check('allFeeActiveUser:list')")
    public ResponseEntity<Object> allFeeActiveUser(AllFee allfee, Pageable pageable){
        Map mapResult = iRunDataService.allFeeActiveUser(allfee,pageable);
        return new ResponseEntity<>(PageUtil.toPage(mapResult.get("list"),mapResult.get("total")), HttpStatus.OK);
    }

    @Log("查询游戏对局输分")
    @ApiOperation("查询游戏对局输分")
    @GetMapping(value="gamelostGold")
    @PreAuthorize("@el.check('gamelostGold:list')")
    public ResponseEntity<Object> gamelostGold(LostGold lostGold, Pageable pageable){
        Map mapResult = iRunDataService.gamelostGold(lostGold,pageable);
        return new ResponseEntity<>(PageUtil.toPage(mapResult.get("list"),mapResult.get("total")), HttpStatus.OK);
    }

    @Log("查询运营埋点数据")
    @ApiOperation("查询运营埋点")
    @GetMapping(value="runData")
    @PreAuthorize("@el.check('runData:list')")
    public ResponseEntity<Object> runData(OperationRecEntity operationRecEntity, Pageable pageable){
        Map mapResult = iRunDataService.runData(operationRecEntity,pageable);
        return new ResponseEntity<>(PageUtil.toPage(mapResult.get("list"),mapResult.get("total")), HttpStatus.OK);

    }

    @Log("查询美团换话费版埋点")
    @ApiOperation("查询美团换话费版埋点")
    @GetMapping(value="getMeituMai")
    @PreAuthorize("@el.check('runData:list')")
    public ResponseEntity<Object> getMeituMai(MeituanMaiInfo meituanMaiInfo, Pageable pageable){
        Map mapResult = iRunDataService.getMeituMai(meituanMaiInfo,pageable);
        return new ResponseEntity<>(PageUtil.toPage(mapResult.get("list"),mapResult.get("total")), HttpStatus.OK);

    }
    @Log("查询美团换话费版10局留存")
    @ApiOperation("查询美团换话费版10局留存")
    @GetMapping(value="getMeituStay")
    @PreAuthorize("@el.check('runData:list')")
    public ResponseEntity<Object> getMeituTen(MeituanReStay meituanReStay, Pageable pageable){
        Map mapResult = iRunDataService.getMeituTen(meituanReStay,pageable);
        return new ResponseEntity<>(PageUtil.toPage(mapResult.get("list"),mapResult.get("total")), HttpStatus.OK);

    }


    @Log("查询运营累计充值")
    @ApiOperation("查询运营累计充值")
    @GetMapping(value="cumRecharge")
    @PreAuthorize("@el.check('runData:list')")
    public ResponseEntity<Object> cumRecharge(CumRechargeEntity cumRechargeEntity, Pageable pageable){
        Map mapResult = iRunDataService.cumRecharge(cumRechargeEntity,pageable);
        return new ResponseEntity<>(PageUtil.toPage(mapResult.get("list"),mapResult.get("total")), HttpStatus.OK);

    }

    @PostMapping(value = "getCumRecharge")
    @PreAuthorize("@el.check('runData:list')")
    public List<CumRechargeEntity> getCumRecharge(@Validated @RequestBody Integer time){
        List<CumRechargeEntity> getCumRecharge = iRunDataService.getCumRecharge(time);
        return getCumRecharge;
    }


    @Log("查询猜大小统计")
    @ApiOperation("查询猜大小统计")
    @GetMapping(value="bigorsmall")
    @PreAuthorize("@el.check('bigorsmall:list')")
    public ResponseEntity<Object> bigOrSmall(BigOrSmallEntity bigOrSmallEntity, Pageable pageable){
        System.out.println(bigOrSmallEntity);
        Map mapResult = iRunDataService.bigOrSmall(bigOrSmallEntity,pageable);
        return new ResponseEntity<>(PageUtil.toPage(mapResult.get("list"),mapResult.get("total")), HttpStatus.OK);

    }
}
